Enable TFLite model parsing with FlatBuffer support and comprehensive TFLite enhancements#146
Enable TFLite model parsing with FlatBuffer support and comprehensive TFLite enhancements#146tdarote wants to merge 4 commits intoqualcomm-linux:mainfrom
Conversation
recipes-ml/tflite/files/0001-lite-Add-config-option-to-enable-benchmark_model.patch
Outdated
Show resolved
Hide resolved
recipes-ml/tflite/files/0002-cmake-lite-tools-benchmark-require-protobuf-through-.patch
Outdated
Show resolved
Hide resolved
recipes-ml/tflite/files/0003-feat-tflite-Add-dynamic-OpenCL-library-loading-suppo.patch
Outdated
Show resolved
Hide resolved
recipes-ml/tflite/files/0004-cmake-Exclude-subdirectories-from-all-builds.patch
Outdated
Show resolved
Hide resolved
|
Waiting for the patches to be posted upstream |
recipes-ml/tflite/files/0005-c-Force-delegate-symbols-from-shared-library.patch
Show resolved
Hide resolved
lumag
left a comment
There was a problem hiding this comment.
Please fix commit subject for the flatbuffers patch
recipes-ml/tflite/files/0002-cmake-lite-tools-benchmark-require-protobuf-through-.patch
Outdated
Show resolved
Hide resolved
175b3f6 to
3ae95c6
Compare
-updated upstream status to submitted |
recipes-ml/tflite/files/0008-cmake-Add-install-rule-for-c-interface-shared-librar.patch
Show resolved
Hide resolved
recipes-ml/tflite/files/0002-cmake-lite-tools-benchmark-require-protobuf-through-.patch
Outdated
Show resolved
Hide resolved
recipes-ml/tflite/files/0002-cmake-lite-tools-benchmark-require-protobuf-through-.patch
Outdated
Show resolved
Hide resolved
DONE |
|
Okay. Upstream (meta-oe) uses flatbuffers 25.12.19. To prevent possible issues with other packages which might depend on that version, we need to provide a separate version of the recipe (flatbuffers-tflite.bb, |
--done |
|
This doesn't build in my test system: |
|
Please explain why this flatbuffer recipe is needed, why the one from meta-oe is not enough, differences, etc, as part of your git commit message. |
If we are using flatbuffers version from meta-oe then we are facing below config issue as : | /local/mnt/workspace/tushar/kas-tflite-build/build/tmp/work/armv8-2a-qcom-linux/tensorflow-lite/2.20.0.qcom/sources/tensorflow-lite-2.20.0.qcom/tensorflow/compiler/mlir/lite/schema/schema_generated.h:25:41: error: static assertion failed: Non-compatible flatbuffers version included |
quaresmajose
left a comment
There was a problem hiding this comment.
I apologize for raising more suggestions, but I promise this is the last one from me.
| TF_LITE_PATCH = "0" | ||
| TF_LITE_BRANCH = "r${TF_LITE_MAJOR}.${TF_LITE_MINOR}" | ||
|
|
||
| SRCREV_FORMAT = "tensorflow_farmhash_gemmlowp_cpuinfo_mlDtypes_ruy_openclHeaders_vulkanHeaders_xnnpack_fft2d_fp16_kleidiai_pthreadpool_fxdiv" |
There was a problem hiding this comment.
will be good to keep this also sorted
There was a problem hiding this comment.
As part of the latest commit, TensorFlow (being the main project) is now listed first. All remaining entries are sorted, and the variable ordering is kept consistent with the SRC_URI layout.
| git://github.com/ARM-software/kleidiai.git;protocol=https;branch=main;name=kleidiai;destsuffix=${S}/kleidiai \ | ||
| git://github.com/google/pthreadpool.git;protocol=https;branch=main;name=pthreadpool;destsuffix=${S}/pthreadpool \ | ||
| git://github.com/Maratyszcza/FXdiv.git;protocol=https;branch=master;name=fxdiv;destsuffix=${S}/FXdiv \ | ||
| https://www.apache.org/licenses/LICENSE-2.0.txt \ |
There was a problem hiding this comment.
We dont need to fectch the apache licenses because they are already available in oe-core at ${COMMON_LICENSE_DIR}/Apache-2.0 And we can copy within the do_configure like you did.
There was a problem hiding this comment.
Yes, addressed. Since the Apache‑2.0 license is already available under ${COMMON_LICENSE_DIR}/Apache-2.0, there’s no need to fetch it separately. I’ve updated the recipe to simply copy it during do_configure, consistent with how other recipes handle common licenses.
| # Command used: sha256sum LICENSE-2.0.txt | ||
| # This is included for informational purposes only | ||
| # The actual source verification happens through git commit hashes in SRCREV values | ||
| SRC_URI[sha256sum] = "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30" |
There was a problem hiding this comment.
With the ${COMMON_LICENSE_DIR}/Apache-2.0 that will be droped
| ln -sf ${S}/fft2d/src/fft2d/fft2d fft2d | ||
|
|
||
| mkdir -p opengl_headers | ||
| cp ${WORKDIR}/sources/LICENSE-2.0.txt opengl_headers/opengl_headers_LICENSE.txt |
There was a problem hiding this comment.
Here we can copy from oe-core license ${COMMON_LICENSE_DIR}/Apache-2.0
| cp ${WORKDIR}/sources/LICENSE-2.0.txt opengl_headers/opengl_headers_LICENSE.txt | ||
|
|
||
| mkdir -p egl_headers | ||
| cp ${WORKDIR}/sources/LICENSE-2.0.txt egl_headers/egl_headers_LICENSE.txt |
No worries — thanks for all the suggestions. I’ve addressed all. |
Thanks |
| @@ -0,0 +1,271 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
✖ source-license-headers-exist: The first 200 lines do not contain the pattern(s): Copyright(\s)*(\(c\)|©)?, SPDX-License-Identifier|Redistribution and use in source and binary forms, with or without (recipes-ml/tflite/files/extract_tflite_srcrevs_from_github.py)
We need a license definition for this file.
There was a problem hiding this comment.
updated license info in file, can you please check once
|
Trying to build yesterdays version of this PR for RB1 results in this: Checking the build folder, only the static library is present. |
can you check now ? |
|
Hi @lumag, |
It works now, thanks! |
Each AI framework and CamX currently rely on different versions of protobuf, leading to inconsistencies across the stack. Attempts to align the protobuf versions for LiteRT and TFLite resulted in functional regressions, indicating that modifying individual AI frameworks to support alternative versions is not a sustainable solution. A similar issue exists with FlatBuffer, where version mismatches create comparable challenges. |
Having a fork of the protobuf library for each component is still not scalable and makes maintaining such a solution cumbersome. The best approach would be to use static linking each component |
CamX is provided directly by Qualcomm, so its dependency alignment is generally not a concern. However, all other AI frameworks in the stack originate from external sources, which introduces additional constraints and makes version harmonization more challenging. |
In my opinion the ones provided in binary form by Qualcomm are the problematic ones because they will be constantly colliding with the open versions as soon as these are updated. |
The issue in this patch is that it introduces a separate FlatBuffers version exclusively for TFLite. This is required because TFLite is not compatible with the FlatBuffers version provided by the latest Yocto release. The same incompatibility exists for Protobuf and FlatBuffers in LiteRT and LlamaCPP, and other AI frameworks have not yet been evaluated. |
…nd C API Apply multiple patches to enhance TensorFlow Lite functionality: - Add benchmark_model config option - Fix protobuf dependency in benchmark tools - Add dynamic OpenCL library loading support - Exclude subdirectories from all builds - Force delegate symbols from shared library - Add version support to C API - Fix label_image dependencies - Add install rule for C interface shared library Signed-off-by: Tushar Darote <tdarote@qti.qualcomm.com>
This pull request enables TFLite model parsing capabilities by integrating FlatBuffer support and implements comprehensive enhancements to the TFLite recipe.
Key Changes:
-> FlatBuffer Integration for TFLite:
- Added flatbuffer bbappend file to enable TFLite's schema handling capabilities for model parsing
-> Comprehensive TFLite Enhancements:
- Added benchmark_model config option
- Fixed protobuf dependency in benchmark tools
- Added dynamic OpenCL library loading support
- Excluded subdirectories from all builds
- Force delegate symbols from shared library
- Add version support to C API
- Fix label_image dependencies
- Add install rule for C interface shared library